//https://leetcode.cn/problems/visit-array-positions-to-maximize-score/solutions/2806895/fang-wen-shu-zu-zhong-de-wei-zhi-shi-fen-jyjg/?envType=daily-question&envId=2024-06-14

class Solution {
public:
    long long maxScore(vector<int>& nums, int x) {
        vector<int> dp(100005);
        int size = nums.size();
        long long oldnum = nums[0];
        long long even = nums[0];
        if(nums[0]%2){
            even -=x;
        }else{
            oldnum-=x;
        }
        for(int i = 1; i<size;i++){
            if(nums[i]%2 == 1){
                oldnum = max(oldnum,even - x) + nums[i];
            }else{
                even = max(oldnum - x,even) + nums[i];
            }
        }
        return max(oldnum,even);
    }
};